package com.cxw.healthserver.utils

import java.net.InetAddress
import java.net.UnknownHostException


/**
 * @createTime 2024/2/21 16:00
 * @author 崔兴旺
 * @description
 */
class IpUtils {
    companion object {
        fun getLocalIpAddress(): String {
            try {
                val localhost = InetAddress.getLocalHost()
                return localhost.hostAddress
            } catch (e: UnknownHostException) {
                e.printStackTrace()
                // 如果无法获取本机 IP 地址，则返回一个默认值或者抛出异常
                return "127.0.0.1"
            }
        }
    }
}